module Receptors

"""
    Receptor

Holds receptor metadata (name, lat, lon, alt).
"""
Base.@kwdef struct Receptor
    name::String
    lat::Float64
    lon::Float64
    alt::Float64
end

"""
    read_reclist(path::AbstractString) -> Vector{Receptor}

Reads a receptor list file with lines like: `AAA  33.01 113.50  120.0`.
Accepts 3- or 4-character station codes as in Fortran.
"""
function read_reclist(path::AbstractString)
    isfile(path) || error("read_reclist: cannot open $(path)")
    recs = Receptor[]
    open(path, "r") do io
        for line in eachline(io)
            s = strip(line)
            isempty(s) && continue
            parts = split(s)
            length(parts) < 4 && error("read_reclist: malformed line: $(line)")
            name = parts[1]
            lat  = parse(Float64, parts[2])
            lon  = parse(Float64, parts[3])
            alt  = parse(Float64, parts[4])
            push!(recs, Receptor(; name, lat, lon, alt))
        end
    end
    return recs
end

end # module

